﻿using System.ClientModel;
using OpenAI;
using OpenAI.Chat;

// var apiKey = "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";
// var baseUrl = "https://openrouter.ai/api/v1";
//
// var client = new ChatClient("qwen/qwen3-235b-a22b-07-25:free", new ApiKeyCredential(apiKey), new OpenAIClientOptions()
// {
//     Endpoint = new Uri(baseUrl),
// });

var apiKey = "sk-zdagxhiekuxfpdnhefegkausrbpuurmmugzrlqvpyjzcltdn";
var baseUrl = "https://api.siliconflow.cn/v1";

var client = new ChatClient("Qwen/Qwen3-8B", new ApiKeyCredential(apiKey), new OpenAIClientOptions()
{
    Endpoint = new Uri(baseUrl),
});

// var completion = client.CompleteChatStreamingAsync("帮我写一手关于AI的诗");
var message = new List<ChatMessage>();
var completion = client.CompleteChatStreamingAsync(message,new ChatCompletionOptions()
{
    Tools = {  }
});


// Uncomment the following lines to read the response as it streams
await foreach (var response in completion)
{
    if(response.ContentUpdate != null)
    {
        foreach (var content in response.ContentUpdate)
        {
            Console.Write(content.Text);
        }
    }
}

// Console.WriteLine(completion.Content?[0].Text ?? "No response received.");

Console.ReadKey();

